dnl Process this file with 'autoconf' to produce a 'configure' script
dnl $Id: configure.in,v 7.5 1995/05/21 22:43:38 tom Exp $
AC_REVISION($Revision: 7.5 $)
AC_INIT(c_count.c)
AC_PROG_CC
AC_PROG_INSTALL
AC_GCC_TRADITIONAL
AC_PROG_MAKE_SET

###	use option -with-warnings to turn on all gcc warnings
if test -n "$GCC"
then
AC_ARG_WITH(warnings,
[  --with-warnings         use gcc warnings (used for developing this tool)],
[CFLAGS="$CFLAGS -Wall -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes"])
fi

AC_SUBST(CFLAGS)
AC_SUBST(LIBS)

AC_CONST
AC_STDC_HEADERS
AC_HAVE_HEADERS(stdlib.h getopt.h string.h malloc.h)
AC_HAVE_FUNCS(strchr getopt)

###
AC_MSG_CHECKING(if compiler supports prototypes)
AC_CACHE_VAL(td_cv_ansi_protos,[
	AC_TRY_COMPILE([],
		[extern foo(char a,int b); foo(1,2)],
		[td_cv_ansi_protos=yes],
		[td_cv_ansi_protos=no])])
AC_MSG_RESULT($td_cv_ansi_protos)
test $td_cv_ansi_protos = yes && AC_DEFINE(ANSI_PROTOS)

###
AC_MSG_CHECKING(if getopt is declared)
AC_CACHE_VAL(td_cv_decl_getopt,[
	AC_TRY_COMPILE([
#include "system.h"
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
],
		[extern	void getopt();],
		[td_cv_decl_getopt=no],
		[td_cv_decl_getopt=yes])])
AC_MSG_RESULT($td_cv_decl_getopt)
test $td_cv_decl_getopt = yes && AC_DEFINE(DECLARED_GETOPT)

###	output makefile and config.h
changequote({,})dnl
AC_OUTPUT(makefile config_h,
{
echo creating config.h
sed	-e '/^# /d' \
	-e 's/ -D/\
#define /g' \
	-e 's/\(#define [A-Za-z_][A-Za-z0-9_]*\)=/\1	/g' \
	config_h >config.h
}
echo removing config_h
rm config_h
)
changequote([,])dnl
